package com.imc.api.order.dao;

import com.imc.api.order.pojo.*;
import com.imc.platform.base.category.pojo.Category;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.Query;

import java.util.List;
import java.util.Map;

/**
 * 类描述：商品实现类
 * 开发者：QY
 * 创建时间：2018/9/12 23:51
 **/
@Mapper
public interface IOrderMapper {

    /**
     * QY 2018/9/12 23:52
     * 方法描述：查询所有分校
     **/
    List <Map <String, Object>> querySchoolList(@Param("longitude") String longitude,@Param("latitude")String latitude);

    /**
     * QY 2018/9/13 11:00
     * 方法描述：根据学校ID查询课程
     **/
    List <CategoryDto> queryCategoryListBySchoolId(@Param("parms") Map <String, Object> parms);

    /*
     * YT  2018/10/28 21:14
     * 方法描述：通过学校ID获取分类list
     */
    List <Lesson> querySCategoryListBySchoolId(@Param("parms") Map <String, Object> parms);

    /**
     * QY 2018/9/26 11:24
     * 方法描述：根据学校ID查学校详情
     **/
    Map <String, Object> querySchoolBySchoolId(String schoolId);

    /**
     * QY 2018/9/19 22:47
     * 方法描述：查课程
     **/
    List <Lesson> queryLessonByCategoryId(@Param("keyword") String keyword, @Param("categoryId") String categoryId, @Param("schoolId") String schoolId);

    /**
     * QY 2018/9/13 11:00
     * 方法描述：查询所有筛选条件
     **/
    //课程期数
    List <String> queryLessonDataList();

    /*
     * YT  2018/10/28 21:14
     * 方法描述：班级人数
     */
    List <String> queryClassSizeList();

    /**
     * QY 2018/9/17 14:53
     * 方法描述：根据筛选条件查询
     **/
    List <Lesson> queryCourseBySecCond(@Param("secCondDto") SecCondDto secCondDto);

    /**
     * QY 2018/9/26 22:31
     * 方法描述：根据课程id查询课程详细
     **/
    Lesson queryLessonByLessonId(@Param("parms") Map<String,Object>parms);

    /**
     * QY 2018/9/26 23:01
     * 方法描述：根据课程ID查询课程安排详情
     **/
    List <LessonSchedule> queryLessonSchByParentId(String lessonId);

    /**
     * QY 2018/9/26 23:02
     * 方法描述：根据课程ID获取老师ID
     **/
    List <String> queryTeacherIdListByLessonId(String lessonId);


    /*
     * YT  2018/10/28 21:15
     * 方法描述：通过订单ID状态获取所有的课程信息
     */
    @Select(
            value = " SELECT lesson.id,lesson.photo,lesson.lessonName as title,lesson.price,detail.quantity,lesson.mDesc as mDesc,lesson.videoUrl  from t_lesson lesson\n" +
                    "  left JOIN t_order_detail detail ON detail.goodsId = lesson.id\n" +
                    " left JOIN t_order mOrder on mOrder.id = detail.orderId WHERE detail.orderId = #{orderId} AND mOrder.status = #{status}"
    )
    List <Map <String, Object>> findAllByOrderIdAndStatusEquals(@Param("orderId") Integer orderId, @Param("status") Integer status);

    /*
     * YT  2018/10/28 21:15
     * 方法描述：通过订单ID获取所有的课程信息
     */
//    @Select(
//            value = " SELECT detail.id as detailId,lesson.id,lesson.photo,lesson.lessonName as title,detail.price,detail.quantity,lesson.mDesc as mDesc,lesson.videoUrl,detail.amounts   from t_lesson lesson\n" +
//                    "  left JOIN t_order_detail detail ON detail.goodsId = lesson.id\n" +
//                    "  WHERE detail.orderId = #{orderId} "
//    )
    List <Map <String, Object>> findAllByOrderId(@Param("orderId") Integer orderId);

    /*
     * YT  2018/10/28 21:16
     * 方法描述：获取所有的视频信息
     */
    List <Map <String, Object>> queryVideoList();

    List<Map<String,Object>>queryMealAll(String SchoolId);

    Map <String, Object> queryLessonOrder(@Param("orderId")String orderId);

    List<OrderBill>queryOrderList(@Param("orderBillDto") OrderBillDto orderBillDto);


    List<Map<String,Object>> queryMyLessonList(Map<String,Object> params);

    List<Map<String,Object>> queryMyLessonSchduleList(@Param("detailId")String detailId);

    List<String> getAvailableSchedule(@Param("orderDetailId")String orderDetailId);

    List<Map<String,Object>> queryResumeStock();

    void resumeStock(List<Map<String,Object>> params);

    List<LessonAtt> queryLessonAtt(String lessonId);

}